/**
 * 七牛图片
 *
 * @author xiaomi
 */

export default function (url, width, height, type) {
  url = url.replace(/\?imageView.+$/, '')

  // not support img, eg. svg
  if (/\.svg$/.test(url)) {
    return url
  }

  var params = ''

  if (width || height) {
    type = type || 2

    params += 'imageView2/' + type
  }

  if (height === null && width) {
    height = width
  }
  if (width) {
    params += '/w/' + width
  }
  if (height) {
    params += '/h/' + height
  }

  return url + '?' + params
}
